//
//  ModalLayer.cpp
//  FamousWarrior
//
//  Created by shuaixitao on 13-4-26.
//  Copyright (c) 2013年 Moqikaka. All rights reserved.
//

#include "ModalLayer.h"

CCScene* ModalLayer::scene()
{
    CCScene* scene = CCScene::create();
    ModalLayer* layer = ModalLayer::create();
    scene->addChild(layer);
    
    return scene;
}

ModalLayer::ModalLayer()
{
    
}

ModalLayer::~ModalLayer()
{
    CCLOG("~~ModalLayer");
}

bool ModalLayer::init()
{
    if (!CCLayer::init())
    {
        return false;
    }
    setTouchEnabled(true);
    
    return true;
}

void ModalLayer::registerWithTouchDispatcher()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    CCLayer::registerWithTouchDispatcher();
}

 
CCScene* ModalLayerColor::scene(const ccColor4B& color)
{
    CCScene* scene = CCScene::create();
    ModalLayerColor* layer = ModalLayerColor::create(color);
    scene->addChild(layer);
    
    return scene;
}

ModalLayerColor* ModalLayerColor::create(const ccColor4B& color)
{  
    ModalLayerColor *pRet = new ModalLayerColor();
    if (pRet && pRet->init(color))
    { 
        pRet->autorelease();
        return pRet;
    } 
    else
    {
        delete pRet;
        pRet = NULL;
        return NULL;
    } 
}


ModalLayerColor::ModalLayerColor()
{
    
}

ModalLayerColor::~ModalLayerColor()
{
    
}

bool ModalLayerColor::init(const ccColor4B& color)
{
    if (!CCLayerColor::initWithColor(color))
    {
        return false;
    }
    setTouchEnabled(true);
    
    return true;
}

void ModalLayerColor::registerWithTouchDispatcher()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -129, true);
    CCLayer::registerWithTouchDispatcher();
}
